]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboardManager: Avoid idempotent calls to meta_backend_set_keymap()
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 22 Oct 2018 22:06:36 +0000 (00:06 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 23 Oct 2018 09:45:02 +0000 (09:45 +0000)
But still try to apply the keymap whenever the input sources changed. This
is a different approach to gnome-shell#240 that still avoid redundant
changes to the current keymap, but actually trigger one when input sources
are added.

https://bugzilla.redhat.com/show_bug.cgi?id=1637418

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/691
js/misc/keyboardManager.js

index ae59f00149063a01df3807bc909b8f7838740639..f4001f13010c657bd60c7a05dfefe53c253ce71b 100644 (file)
@@ -52,11 +52,20 @@ var KeyboardManager = new Lang.Class({
         this._current = null;
         this._localeLayoutInfo = this._getLocaleLayout();
         this._layoutInfos = {};
+        this._currentKeymap = null;
     },
 
     _applyLayoutGroup(group) {
         let options = this._buildOptionsString();
         let [layouts, variants] = this._buildGroupStrings(group);
+
+        if (this._currentKeymap &&
+            this._currentKeymap.layouts == layouts &&
+            this._currentKeymap.variants == variants &&
+            this._currentKeymap.options == options)
+            return;
+
+        this._currentKeymap = {layouts, variants, options};
         Meta.get_backend().set_keymap(layouts, variants, options);
     },
 
@@ -89,8 +98,6 @@ var KeyboardManager = new Lang.Class({
     },
 
     setUserLayouts(ids) {
-        let currentId = this._current ? this._current.id : null;
-        let currentGroupIndex = this._current ? this._current.groupIndex : null;
         this._current = null;
         this._layoutInfos = {};
 
@@ -117,9 +124,6 @@ var KeyboardManager = new Lang.Class({
             info.group = group;
             info.groupIndex = groupIndex;
 
-            if (currentId == id && currentGroupIndex == groupIndex)
-                this._current = info;
-
             i += 1;
         }
     },